package com.servlet;


import com.alibaba.fastjson.JSON;
import com.entity.feature.Feature;
import com.service.FeatureService;
import com.service.impl.FeatureServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/// 特性
@WebServlet(name = "FeatureServlet", urlPatterns = {"/FeatureServlet"})
public class FeatureServlet extends AbstractHttpServlet {
	@Override
	public void doHandle(HttpServletRequest request, HttpServletResponse response, PrintWriter out, HttpSession session) throws IOException, ServletException {
		String action = request.getParameter("pro");
		switch (action) {
			case "FeatureList" -> featureList(out);
			case null, default -> {
			}
		}
	}
	
	/// 获取特性
	private static void featureList(PrintWriter out) {
		FeatureService featureService = new FeatureServiceImpl();
		List<Feature> featureList = featureService.getFeatureList();
		String json = JSON.toJSONString(featureList);
		out.print(json);
	}
}
